#include <iostream>
#include <vector>

using namespace std;
class Solution
{
public:
    bool checkXMatrix(vector<vector<int>> &grid)
    {
        int n = grid.size();
        for (size_t i = 0; i < n; i++)
        {
            for (size_t j = 0; j < n; j++)
            {
                if (i == j || i + j == n - 1)
                {
                    if (grid[i][j])
                    {
                        return false;
                    }
                }
                else
                {
                    if (!grid[i][j])
                    {
                        return false;
                    }
                }
            }
        }
        return true;
    }
};
int main()
{
    Solution s;
    vector<vector<int>> grid = {{5, 7, 0}, {0, 3, 1}, {0, 5, 0}};
    cout << s.checkXMatrix(grid) << endl;
    return 0;
}